-
Notifications
You must be signed in to change notification settings - Fork 126
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Add monthly report support #6508
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
UXQA:
- The "Create" button should be disabled until the all the form's required fields are input & when there's input validation errors.
- The "Invalid" text should be left-aligned with the main body of the form (and it should be a more informative message).
- The "repeats" section should be written in more natural English, e.g. "on the 31st of each month"
- I see that when the next month doesn't have the provided day, like February 30th, the report is skipped for that month. @mindspank, can you please do the Product review for this PR? Is this what you'd expect?
I would expect the report to run on the 28th in this case. Same for reports scheduled to run on 31st I would expect to run on the 30th if there is no 31 for the next month. Alternatively if we had "First day" and "Last day" as options we can keep the existing behavior. (Realizing First day is redundant but to match the Last day option) |
Disabled the input for now. |
d972f41
to
f2025d9
Compare
const suffixMap = { | ||
1: "st", | ||
2: "nd", | ||
3: "rd", | ||
}; | ||
export function formatRefreshSchedule(reportSpec: V1ReportSpec) { | ||
if (!reportSpec.refreshSchedule?.cron) return ""; | ||
let formattedRefreshSchedule = cronstrue.toString( | ||
reportSpec.refreshSchedule.cron, | ||
{ | ||
verbose: true, | ||
}, | ||
); | ||
formattedRefreshSchedule = formattedRefreshSchedule.replace( | ||
/on day (\d*) of the month/, | ||
(_, day: number) => { | ||
const suffix = suffixMap[day % 10] ?? "th"; | ||
return `on the ${day}${suffix} of each month`; | ||
}, | ||
); | ||
|
||
return formattedRefreshSchedule; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's a ChatGPT convo with a cleanup proposal: link
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
convertFormValuesToCronExpression()
and getFrequencyFromCronExpression()
could use some unit tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True. None of this code has any tests.
dd3abe0
to
867042b
Compare
closes #6503